home *** CD-ROM | disk | FTP | other *** search
/ NOVA - For the NeXT Workstation / NOVA - For the NeXT Workstation.iso / Documents / NeXTAnswers / hardware.422 < prev    next >
Text File  |  1992-02-06  |  812b  |  38 lines

  1.  
  2. Q: How can a program determine which CPU board revision is in the computer being used?
  3.  
  4. A: Use the table() system call (not documented).  Sample code:
  5.  
  6. #include <sys/table.h>        /* Not really necessary, but nice for completeness */
  7. #include <machine/table.h>
  8. #include <machine/cpu.h>
  9. #include <stdio.h>
  10.  
  11. extern int table(int id, int index, caddr_t address, int n_elements, int element_size);
  12.  
  13. main(argc, argv)
  14. int    argc;
  15. char    *argv[];
  16. {
  17.     int    res;
  18.     unsigned    cpu_rev;
  19.     int    error;
  20.  
  21.     res = table(TBL_NeXT_CPU_REV, 0, (char *)&cpu_rev, 1, sizeof(cpu_rev));
  22.     if (res == -1) {
  23.         perror(argv[0]);
  24.         (void)fprintf(stderr, "%s: unable to get table value.\n", argv[0]);
  25.         exit(1);
  26.     } else {
  27.         (void)printf("%s: table returned; res=%d, cpu_rev=%d.\n",    
  28.                 argv[0], res, cpu_rev);
  29.     }
  30. }
  31.  
  32. QA422
  33.  
  34. Valid for 1.0 
  35. Valid for 2.0 
  36.  
  37.  
  38.